home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / m68k / 304 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  5.8 KB

  1. Path: bcarh8ab.bnr.ca!rpcook
  2. From: rpcook@bnr.ca (Richard Cook)
  3. Newsgroups: comp.sys.m68k
  4. Subject: Re: Help with setting up 68040 MMU req'd
  5. Date: 29 Feb 1996 00:31:23 GMT
  6. Organization: Bell-Northern Research Ltd.
  7. Message-ID: <4h2s4r$2b4@bcarh8ab.bnr.ca>
  8. References: <4h0i0s$84a@myall.awadi.com.au>
  9. NNTP-Posting-Host: bcarhd5a.bnr.ca
  10. Keywords: 68040, 68030 MMU
  11.  
  12. In article <4h0i0s$84a@myall.awadi.com.au>,
  13. Kym Newbery <knewbery@awadi.com.au> wrote:
  14. >
  15. >    I am seeking somebody would can help me, or provide a pointer to
  16. >information on how to setup the MMU in a home-grown 68040 processor board. 
  17. >I have read the 68040 users guide back-to-front and tried to understand the 
  18. >section on the MMU but there are no worked examples which makes understanding 
  19. >the MMU difficult.  
  20.  
  21. I have implemented a 68060 MMU table and it is the same as the 68040.
  22.  
  23. >    What I would like to do is to write protect a block of SRAM.  The 
  24. >processor we have built has SRAM from address 0x02000000 to 0x021fffff (2Mega
  25. >bytes, 512Klongwords worth).  I would like to be able to write data/code into
  26. >the top section from 0x02100000 to 0x021fffff then turn on the MMU and write
  27. >protect it.  I realise that I will need to create a translation table in RAM
  28. >somewhere - the problem is how big a translation table do I require ??.. does
  29. >it have to all the three levels of tables??, or can somebody describe what is
  30. >required?  I'm a bit worried that we will have to create a huge translation 
  31. >table to implement a simple memory protection scheme.
  32.  
  33. Okay, first, you will need all three levels of the MMU tables, but you don't 
  34. need to fill in all the entries.  The root pointer(s) will point to the
  35. first level table.  This table must be aligned on a 512 byte boundary and
  36. each entry covers 32 Megs of your memory map.  There are 128 entries of 4
  37. bytes each.  Initialize this all to zeros and fill in only those entries
  38. that are applicable to your memory map (ROM, SRAM, I/O if you want) with
  39. pointers to the second level table(s).
  40.  
  41. The least significant 2 bits of each entry, when set to zero, tells the 
  42. processor that this is an 'INVALID' entry and access to this address
  43. range will generate a bus error.
  44.  
  45. The second level tables cover 256K each.  Again, these are 128 entry tables
  46. of 4 bytes each, which must be aligned on a 512 byte boundary (simply put it
  47. right after the first table).  Again, zero these tables and fill in only those
  48. that you need with pointers to the third level tables.
  49.  
  50. The third level are 32 entry tables of 4 bytes each.  Well, they are if you
  51. choose 8K coverage.  Your only other choice is 4K coverage, but I don't
  52. remember the details for it.  If I remember correctly, each 3-rd level table
  53. must be aligned on a 128 byte boundary.
  54.  
  55. These boundaries are required as the processor uses bits from the virtual (or
  56. effective) address as an offset into the table(s).
  57.  
  58. So, excluding your ROM and I/O, the 2 Meg SRAM will require one top level
  59. table (512 bytes), with the second entry pointing to the only second level
  60. table.  The second level table will require 8 entries to point to 8 third
  61. level tables (which can all be allocated right after the second level table).
  62. These 8 entries will cover all of the 2 Meg SRAM.  You can set the
  63. write-protection bits at this level on the last 4 entries to cover the 1 Meg
  64. of program/data you mentioned.  The 8 third level tables will require 1K (8 *
  65. 32 entries * 4 bytes/entry) for a total of 2K for your MMU tables.
  66.  
  67. >
  68. >    Also, we have implemented a hardware protection mechanism that asserts
  69. >TEA when an access to non-allocated memory space is made (this then causes
  70. >an access/bus error)  _and_ we would like to be able to cache the SRAM block
  71. >but not our I/O block (which is located up near 0x0C400000 to 0x0C40FFFF).
  72. >(I am using the TT registers to do this).
  73.  
  74. You may also use the MMU tables for caching the SRAM and cache-inhibiting the
  75. I/O (I did).  You can use the TT registers to cover your ROM and/or I/O if you
  76. like, (depends on design, frequency of turning on and off cache,
  77. write-protection, whatever).
  78.  
  79. NOTE:  The manual recommends that you mark the MMU tables themselves, as cache
  80. inhibited.  It is not required on the 68040, but manditory on the 68060 as the
  81. processor by-passes the cache when doing an MMU table walk/search.
  82.  
  83. I tried having my MMU tables cover the data section and the transparent
  84. translation registers cover the program section and part of my I/O.
  85.  
  86. This way I could change the write-protection on the program store all at once
  87. by just changing one register (rather than updating many entries in the MMU
  88. table).  Note, also that the TT registers cover memory starting on a 16 Meg
  89. boundary (multiple?).  i.e. any one 16 Meg section, or a 32 Meg section
  90. starting at 0, 32 Meg, 64 Meg, etc., or a 64 Meg section starting at 0, 64
  91. Meg, 128 Meg, etc., etc., etc., ....   not too handy when you want to
  92. cover a section, perhaps 1 Meg, in the SRAM.
  93.  
  94. Also, beware of using copyback cache mode with write-protected storage.
  95. If you unprotect memory, write to it, then protect it again ... the data is in
  96. the data cache with the dirty data bit on, it never went to the actual
  97. storage.  When the cache is later flushed, or the cache line is reused, the
  98. dirty data will, at that time, be written our to the now write protected
  99. storage and, voila, a bus error!
  100.  
  101. The use of the TEA for your bus errors is required when the MMU is turned off
  102. but should not be needed when using the MMU tables.  As soon as the processor
  103. finds and 'invalid' entry in the MMU tables, it will generate an internal bus
  104. error, so the address will not make it out to the data bus at all.
  105.  
  106. Good luck.  And if you find an algorithm for determining the instruction
  107. length given an address in program storage, let me know ... I am working on a
  108. bus error handler that needs it on the 68060.
  109.  
  110. -- 
  111.  
  112. Richard Cook          NOTE:  my e-mail id has changed!  (was rcooke@bnr.ca)
  113. (613) 765-4882
  114. rpcook@nortel.ca      My opinions are not necessarily NORTEL / BNR's.
  115.